<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../../assets/libs/jquery/jquery-3.6.1.min.js"></script>
</head>

<body>
  <button>按钮</button>

  <script>
    // 注册事件监听
    $('button').click(() => {
      console.log('click')
    })

    // on 注册事件监听
    $('button').on('click', () => {
      console.log('click')
    })

    // on 注册多种事件监听，共用同一个回调函数
    $('button').on('click dblclick', (event) => {
      console.log(event.type)
    })

    // on 注册多种事件监听
    $('button').on({
      click: () => {
        console.log('click')
      },
      dblclick: () => {
        console.log('dblclick')
      }
    })

    // 注销事件监听
    $('button').off('click')

    // 注销多种事件监听
    $('button').off('click dblclick')

    // 注销所有事件监听
    $('button').off()
  </script>
</body>

</html>